//205.同构字符串
//https://leetcode.cn/problems/isomorphic-strings/
class Solution {
public:
    bool isIsomorphic(string s, string t) {
        unordered_map<char,int> hash1,hash2;
        int n = s.size();
        for(int i = 0;i<n;++i)
        {
            //在hash1和hash2中建立s和t的每个字符的映射关系 当出现错误时 返回false
            if((hash1.count(s[i]) && hash1[s[i]] != t[i])
            || (hash2.count(t[i]) && hash2[t[i]] != s[i])) return false;
            hash1[s[i]] = t[i];
            hash2[t[i]] = s[i];
        }
        return true;
    }
};
